import 'package:flutter/material.dart';

class MessageItem extends StatelessWidget {
  final String avatarUrl; // 头像URL
  final String nickName; // 昵称
  final String time; // 发布时间
  final String content; // 朋友圈内容
  final List<String> imageUrls; // 朋友圈图片URL列表，可为空
  final int likeCount; // 点赞数
  final int commentCount; // 评论数
  final int forwardCount; // 转发数

  const MessageItem({
    Key? key,
    required this.avatarUrl,
    required this.nickName,
    required this.time,
    required this.content,
    this.imageUrls = const [],
    this.likeCount = 0,
    this.commentCount = 0,
    this.forwardCount = 0,
  }) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return Column(
      crossAxisAlignment: CrossAxisAlignment.start,
      children: [
        // 头部信息（头像、昵称、发布时间）
        ListTile(
          leading: CircleAvatar(
            backgroundImage: NetworkImage(avatarUrl),
          ),
          title: Text(nickName),
          subtitle: Text(time),
        ),
        // 朋友圈内容文本
        Padding(
          padding: const EdgeInsets.symmetric(horizontal: 16.0,),
          child: Text(content),
        ),
        // 朋友圈图片展示（如果有图片）
        if (imageUrls.isNotEmpty)
          SizedBox(
            height: 100, // 图片展示区域高度，可调整
            child: ListView.builder(
              scrollDirection: Axis.horizontal,
              itemCount: imageUrls.length,
              itemBuilder: (context, index) {
                return Padding(
                  padding: const EdgeInsets.all(4.0),
                  child: Image.network(
                    imageUrls[index],
                    fit: BoxFit.cover,
                  ),
                );
              },
            ),
          ),
        // 操作栏（点赞、评论、转发及对应数量）
        Padding(
          padding: const EdgeInsets.symmetric(horizontal: 16.0),
          child: Row(
            children: [
              IconButton(
                icon: Icon(Icons.thumb_up_alt),
                onPressed: () {}, // 点赞点击逻辑，待完善
              ),
              Text('$likeCount'),
              SizedBox(width: 16),
              IconButton(
                icon: Icon(Icons.comment),
                onPressed: () {}, // 评论点击逻辑，待完善
              ),
              Text('$commentCount'),
              SizedBox(width: 16),
              IconButton(
                icon: Icon(Icons.repeat),
                onPressed: () {}, // 转发点击逻辑，待完善
              ),
              Text('$forwardCount'),
            ],
          ),
        ),
        Divider(height: 1), // 分割线，区分不同的朋友圈信息
      ],
    );
  }
}